import java.util.Scanner;

public class Class3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String str = scanner.next();
        int m = str.length();
        char[][] chars = new char[n][n];
        for (int i=0;i<n;i++){
            chars[i] = scanner.next().toCharArray();
        }
        int ans = 0;
        for(int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                if (j+m-1<n){
                    int temp_j = j;
                    boolean flag = true;
                    for (int k=0;k<m;k++){
                        if (str.charAt(k)!=chars[i][j]){
                            flag = false;
                            break;
                        }
                        k++;
                        j++;
                    }
                    if (flag){
                        ans++;
                    }
                    j = temp_j;
                }
                if (i+m-1<n){
                    int temp_i = i;
                    boolean flag = true;
                    for (int k=0;k<m;k++){
                        if (str.charAt(k)!=chars[i][j]){
                            flag = false;
                            break;
                        }
                        k++;
                        i++;
                    }
                    if (flag){
                        ans++;
                    }
                    i = temp_i;

                }
            }


        }
        System.out.println(ans);
    }
}
